<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
	<meta http-equiv="Content-type" content="text/html;charset=utf-8">
	<title>Magic the Gathering Card Collection Tool</title>
  <link rel="stylesheet" type="text/css" href="./styles/default.css">
  <link rel="stylesheet" type="text/css" href="./styles/menu.css">
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js" type="text/javascript"></script>
</head>

<body>

<?php
  include dirname(__FILE__)."/includes/header.inc.php";

  include dirname(__FILE__)."/includes/menu.inc.php";

if(isset($_GET["username"]))
{
  include_once dirname(__FILE__)."/database/database.class.php";

  $ID = $db->getUserID($_GET["username"]);
  if($ID > 0)
  {
    setcookie("MGTDatabase_user", $ID);
    $_COOKIE["MGTDatabase_user"]=$ID;
  }
}

if(isset($_GET["logout"]) && isset($_COOKIE["MGTDatabase_user"]))
{
  setcookie("MGTDatabase_user", "", time()-3600);
  unset($_COOKIE["MGTDatabase_user"]);
}

if(!isset($_COOKIE["MGTDatabase_user"]))
{
  echo '<form action=".">
          <p>
            User: <input type="text" name="username"><input type="submit" value="Login">
          </p>
        </form>';
}
else
{
  echo '<form action=".">
        <p>
          <input type="hidden" name="logout" value="true">
          <input type="submit" value="Logout">
        </p>
      </form>';
}

include dirname(__FILE__)."/includes/footer.inc.php";
?>
</body>‎
</html>
